﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SLServiceLibrary
{
    public class City
    {
        private List<decimal> parentValueList = new List<decimal>();

        public List<decimal> ParentValueList
        {
            get { return parentValueList; }
            set { parentValueList = value; }
        }


        public City clone() 
        {
            City newCity = new City();

            newCity.CityName = this.CityName;

            //this.PointList = this.PointList;
            for (int i = 0; i < this.PointList.Count; i++)
            {
                newCity.PointList.Add(this.PointList[i].clone());
            }

            //this.ValueList = this.ValueList;
            for (int i = 0; i < this.ValueList.Count; i++)
            {
                newCity.ValueList.Add(this.ValueList[i]);
            }
            //this.TimeList = this.TimeList;
            for (int i = 0; i < this.TimeList.Count; i++)
            {
                newCity.TimeList.Add(this.TimeList[i]);
            }
            //this.CountryList = this.CountryList;
            for (int i = 0; i < this.CountryList.Count; i++)
            {
                newCity.CountryList.Add(this.CountryList[i]);
            }

            return newCity;
        }
        private string cityName;

        public string CityName
        {
            get { return cityName; }
            set { cityName = value; }
        }

        private List<Point> pointList = new List<Point>();

        public List<Point> PointList
        {
            get { return pointList; }
            set { pointList = value; }
        }

        private List<Decimal> valueList = new List<decimal>();

        public List<Decimal> ValueList
        {
            get { return valueList; }
            set { valueList = value; }
        }
        private List<DateTime> timeList = new List<DateTime>();

        public List<DateTime> TimeList
        {
            get { return timeList; }
            set { timeList = value; }
        }
        private List<Decimal> xDiList = new List<decimal>();
        //[DataMember]
        public List<Decimal> XDiList
        {
            get { return xDiList; }
            set { xDiList = value; }
        }
        private List<Decimal> yDiList = new List<decimal>();
        //[DataMember]
        public List<Decimal> YDiList
        {
            get { return yDiList; }
            set { yDiList = value; }
        }
        private List<decimal> diList = new List<decimal>();
        //[DataMember]
        public List<decimal> DiList
        {
            get { return diList; }
            set { diList = value; }
        }

        private List<Country> countryList = new List<Country>();

        public List<Country> CountryList
        {
            get { return countryList; }
            set { countryList = value; }
        }

        public Decimal GetValueByTime(DateTime time)
        {
            return this.valueList[this.timeList.IndexOf(time)];
        }
        public Decimal GetDiByTime(DateTime time)
        {
            return this.DiList[this.timeList.IndexOf(time)];
        }
        public Decimal GetXDiByTime(DateTime time) { return this.XDiList[this.timeList.IndexOf(time)]; }

        public Decimal GetYDiByTime(DateTime time) { return this.YDiList[this.timeList.IndexOf(time)]; }

        public Decimal GetParentValueByTime(DateTime time) { return this.parentValueList[this.timeList.IndexOf(time)]; }
        public void countDi()
        {
            //循环拿到年份
            foreach (var year in this.timeList)
            {
                this.DiList.Add(this.GetValueByTime(year) / this.GetParentValueByTime(year));
            }

        }
       private Point GetPointByTime(DateTime time){return this.PointList[this.TimeList.IndexOf(time)];}
        public void counXYDi()
        {
            foreach (var year in this.timeList)
            {
                this.XDiList.Add(this.GetDiByTime(year) * Convert.ToDecimal(this.GetPointByTime(year).X));

                this.YDiList.Add(this.GetDiByTime(year) * Convert.ToDecimal(this.GetPointByTime(year).Y));
            }
        }
    }
}
